---
# Configuration for the Fedora Notifications webapp

- name: install needed packages
  package: name={{ item }} state=present
  with_items:
  - statscache-web
  - statscache-plugins
  - python-psycopg2
  - libsemanage-python
  notify:
  - restart apache
  tags:
  - statscache
  - statscache/frontend

- name: copy statscache app configuration
  template: >
    src={{ item }} dest=/etc/fedmsg.d/{{ item }}
    owner=apache group=apache mode=0600
  with_items:
  - statscache.py
  notify:
  - restart apache
  tags:
  - statscache
  - statscache/frontend

- name: copy statscache httpd config
  template: >
    src=statscache.conf dest=/etc/httpd/conf.d/statscache.conf
    owner=apache group=apache mode=0644
  notify:
  - restart apache
  tags:
  - statscache
  - statscache/frontend

- name: copy custom wsgi file
  copy: src=statscache.wsgi dest=/usr/share/statscache/apache/statscache.wsgi mode=0644
  notify:
  - restart apache
  tags:
  - statscache
  - statscache/frontend

- name: copy app configuration
  template: >
    src=statscache.cfg dest=/etc/statscache.cfg
    owner=root group=apache mode=0640
  notify:
  - restart apache
  tags:
  - statscache
  - statscache/frontend

- name: apply selinux type to static files
  file: >
    dest=/usr/share/statscache/static
    setype=httpd_sys_content_t
    state=directory
    recurse=yes
  tags:
  - statscache
  - statscache/frontend
  - selinux

- name: ensure selinux lets httpd talk to postgres
  seboolean: name={{item}} state=yes persistent=yes
  with_items:
  - httpd_can_network_connect_db
  tags:
  - statscache
  - statscache/frontend
  - selinux
